<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>资讯中心</title>
    <style>
        /* --- 全局和基础样式 (与管理后台保持一致) --- */
        :root {
            --sidebar-width: 240px;
            --primary-color: #007bff;
            --border-color: #dee2e6;
            --card-hover-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
            --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background-color: #f4f5f7;
            margin: 0;
            color: #333;
        }

        a {
            text-decoration: none;
            color: var(--primary-color);
            transition: color 0.2s;
        }
        a:hover {
            color: #0056b3;
        }

        /* --- 主要布局 --- */
        /* 模拟的侧边栏样式 */
        .teacher-sidebar-placeholder {
            position: fixed; top: 0; left: 0; height: 100%;
            width: var(--sidebar-width); background-color: #fff;
            box-shadow: 2px 0 5px rgba(0,0,0,0.05); z-index: 1000;
            padding: 20px; box-sizing: border-box; border-right: 1px solid #e9ecef;
        }
        .teacher-sidebar-placeholder h3 { margin-top: 0; color: var(--primary-color); }
        .teacher-sidebar-placeholder ul { list-style: none; padding: 0; }
        .teacher-sidebar-placeholder li a { display: block; padding: 10px; text-decoration: none; color: #333; border-radius: 4px; }
        .teacher-sidebar-placeholder li a:hover { background-color: #f1f1f1; }

        .main-content {
            margin-left: var(--sidebar-width);
            padding: 30px;
        }

        .container-card {
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: var(--card-shadow);
            padding: 25px 30px;
        }

        /* --- 页面头部与功能区 --- */
        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            flex-wrap: wrap;
        }
        .page-header h2 {
            margin: 0;
            font-size: 1.8em;
        }

        .search-form {
            display: flex;
            gap: 10px;
            margin-bottom: 25px;
        }
        .search-form input[type="text"] {
            flex-grow: 1; padding: 8px 12px; border: 1px solid var(--border-color);
            border-radius: 4px; font-size: 1em;
        }
        .search-form input[type="text"]:focus {
            outline: none; border-color: var(--primary-color);
            box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
        }

        /* --- 按钮统一样式 --- */
        .btn {
            display: inline-block; font-weight: 500; text-align: center; vertical-align: middle;
            cursor: pointer; user-select: none; background-color: #f8f9fa;
            border: 1px solid #dee2e6; padding: 8px 15px; font-size: 0.9em;
            border-radius: 4px; transition: all 0.2s ease-in-out;
            text-decoration: none; color: #333;
        }
        .btn:hover { text-decoration: none; filter: brightness(95%); }
        .btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); color: #fff; }

        /* --- 资讯卡片列表 --- */
        .info-list {
            display: grid;
            grid-template-columns: 1fr; /* 默认单列布局 */
            gap: 25px;
        }

        .info-card {
            display: flex;
            align-items: flex-start;
            background: #fff;
            border-radius: 8px;
            box-shadow: var(--card-shadow);
            overflow: hidden; /* 确保图片圆角生效 */
            transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
            position: relative;
        }
        .info-card:hover {
            transform: translateY(-5px);
            box-shadow: var(--card-hover-shadow);
        }

        .info-card-img {
            width: 220px;
            height: 150px;
            object-fit: cover;
            flex-shrink: 0; /* 防止图片被压缩 */
        }

        .info-card-content {
            padding: 15px 20px;
            flex: 1;
            display: flex;
            flex-direction: column;
            height: 120px; /* 使内容区域高度与图片大致匹配，方便对齐 */
        }

        .info-card-content h3 {
            margin: 0 0 8px 0;
            font-size: 1.2em;
            color: #212529;
            /* 限制标题行数，超出显示省略号 */
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
        }

        .info-card-meta {
            font-size: 0.9em;
            color: #6c757d;
            margin-bottom: auto; /* 将元数据推到底部链接之上 */
        }

        .info-card-readmore {
            font-weight: 500;
            align-self: flex-end; /* 将“阅读全文”推到右下角 */
        }

        /* 让整个卡片都可点击 */
        .info-card .card-link {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            text-indent: -9999px; /* 隐藏链接文本 */
            z-index: 1;
        }
        .info-card-content a {
            position: relative;
            z-index: 2; /* 确保内容区的链接在覆盖层之上，可以单独点击 */
        }

    </style>
</head>
<body>
<div th:replace="~{fragments/header :: header}">
    <div class="teacher-sidebar-placeholder">
        <h3>教师后台</h3>
        <ul>
            <li><a href="#">仪表盘</a></li>
            <li><a href="#" style="background-color: #e9ecef; font-weight: bold;">资讯中心</a></li>
            <li><a href="#">学生管理</a></li>
            <li><a href="#">个人设置</a></li>
        </ul>
    </div>
</div>

<div class="main-content">
    <div class="container-card">
        <div class="page-header">
            <h2>资讯中心</h2>
        </div>

        <form th:action="@{/info/browse}" method="get" class="search-form">
            <input type="text" name="keyword" placeholder="搜索资讯..." th:value="${keyword}">
            <button type="submit" class="btn">搜索</button>
        </form>

        <div th:if="${#lists.isEmpty(infoList)}" style="text-align: center; padding: 50px 0;">
            <p>暂未找到相关资讯。</p>
        </div>

        <div class="info-list">
            <div th:each="info : ${infoList}" class="info-card">
                <img th:if="${info.infoImage != null and info.infoImage != '/images/default-info.png'}"
                     th:src="@{${info.infoImage}}"
                     class="info-card-img" alt="资讯封面">
                <img th:unless="${info.infoImage != null and info.infoImage != '/images/default-info.png'}"
                     th:src="@{https://via.placeholder.com/220x150/e9ecef/6c757d?text=No+Image}"
                     class="info-card-img" alt="暂无图片">

                <div class="info-card-content">
                    <h3 th:text="${info.infoTitle}">这里是资讯的标题，可能会比较长，需要测试换行效果</h3>
                    <p class="info-card-meta">
                        作者: <span th:text="${info.teacherName}">教师名称</span> |
                        时间: <span th:text="${#temporals.format(info.createTime, 'yyyy-MM-dd')}">2025-06-16</span>
                    </p>
                    <a th:href="@{/info/detail/{id}(id=${info.id})}" class="info-card-readmore">阅读全文 →</a>
                </div>
                <a th:href="@{/info/detail/{id}(id=${info.id})}" class="card-link" title="阅读全文"></a>
            </div>
        </div>
    </div>
</div>
</body>
</html>